#删除原容器
echo "begin stop and delete old jenkins......"
docker stop jenkins-cqj && docker rm jenkins-cqj
echo "=======================rm over=============================="

# pull mysql images
echo "=======================start pull jenkins images=============================="
docker pull jenkins/jenkins
echo "=======================pull end.=============================="

# check path
jenkins_path="/home/docker/jenkins"
if [[ ! -d "$jenkins_path" ]]; then
	echo "jenkins_path webroot path not exsits,create now."
	mkdir -p ${jenkins_path}
else
	echo "jenkins_path path exsits"
fi

docker run -d \
--network=bridge-chen \
--ip 172.20.1.254 \
-p 10240:8080 \
-v /home/docker:/home/docker \
-v /etc/localtime:/etc/localtime \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /etc/sysctl.conf:/etc/sysctl.conf \
-v /usr/bin/docker:/usr/bin/docker \
-e JAVA_HOME=/home/docker/app/jdk-17 \
-e MAVEN_HOME=/home/docker/app/maven \
-e NODE_HOME=/home/docker/app/node \
-e PATH=$PATH:/home/docker/app/maven/bin:/home/docker/app/node/bin:/home/docker/app/jdk-17/bin \
-e JENKINS_HOME=/home/docker/jenkins \
-u root \
--restart=always \
--privileged=true \
--name jenkins-cqj \
jenkins/jenkins:latest
